package com.buka.mq;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class SpringRabbitListener {

    @RabbitListener(bindings = @QueueBinding(
            value=@Queue(name="topic.queue1"),
            exchange = @Exchange(name="topic.exchange",type= ExchangeTypes.TOPIC),
            key = "china.#"
    ))
    public void onMessage1(String message) {
        System.out.println("消费者1：" + message);
    }




    @RabbitListener(bindings = @QueueBinding(
            value=@Queue(name="topic.queue2"),
            exchange = @Exchange(name="topic.exchange",type= ExchangeTypes.TOPIC),
            key = "#.news"
    ))
    public void onMessage2(String message) {
        System.out.println("消费者2：" + message);
    }


}

